#include <stdio.h>
#define MaxSize 200

void Change(int data[][MaxSize],int row,int col,int key);
void Left_Right(int data[][MaxSize],int row,int col);
void Up_Down(int data[][MaxSize],int row,int col);
void Print(int data[][MaxSize],int row,int col);
void CreatArtix(int data[][MaxSize],int row,int col);

void Change(int data[][MaxSize],int row,int col,int key)
{
    if(key == 0)
        Left_Right(data,row,col);
    else
        Up_Down(data,row,col);
}
void Left_Right(int data[][MaxSize],int row,int col)
{
    int temp;
    for(int i = 0;i < row ; i++)
    {
        for( int j = 0; j< col/2 ; j++)
        {
            temp = data[i][j];
            data[i][j] = data[i][col - j -1];
            data[i][col - j - 1] = temp;
        }
    }
    Print(data,row,col);
}
void Up_Down(int data[][MaxSize],int row,int col)
{
    int temp;
    for(int i = 0;i < row/2 ; i++)
    {
        for( int j = 0; j< col ; j++)
        {
            temp = data[i][j];
            data[i][j] = data[row - i - 1][j];
            data[row - i - 1][j] = temp;
        }
    }
    Print(data,row,col);
}
void Print(int data[][MaxSize],int row,int col)
{
    printf("The result is :\n");
    for(int i = 0;i < row; i++)
    {
        for( int j = 0; j< col ; j++)
        {
            printf("%d ",data[i][j]);
            if( j == col -1)
                printf("\n");
        }
    }
}
void CreatArtix(int data[][MaxSize],int row,int col)
{
    for(int i = 0;i < row ; i++)
    {
        for( int j = 0; j< col ; j++)
        {
            scanf("%d",&data[i][j]);
        }
    }
}

int main()
{
    int row;
    int col;
    int key;
    int data[MaxSize][MaxSize];
    printf("Please enter the size of row & col:\n");
    scanf("%d %d",&row,&col);
    printf("Please tell me the way you want change the artix:\n");
    scanf("%d",&key);
    printf("Please enter the data:\n");
    CreatArtix(data,row,col);
    Change(data,row,col,key);
    return 0;
}